<template>
  <div class="vehicle-details-wrap">
    <div class="box">
      <TopFilter
        ref="searchOrdersPanel"
        :list="searchOrdersList"
        :isSubmitBtn="true"
        :cols="4"
        :label-width="90"
        @filterChange="getOrderList"
        @onCollapse="collapseHandle"
      />
      <!-- <el-row>
        <el-button @click="query" type="primary" >查 询</el-button>
        <el-button @click="reset" >重 置</el-button>
      </el-row> -->
       <!--  :loading="addBtnState" -->
    </div>
    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      selectionType="multiple"
      :datakey="'rows'"
      :onColumnsChange="columns => this.columns = columns"
      :onRowSelectChange="arr => this.onChangeColumn = arr"
    >
      <template slot="controls">
        <!-- <el-button @click="openPayments" type="primary" >收 款</el-button> -->
      </template>
    </FilterTable>
  </div>
</template>

<script>
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
import { getOrderList } from '@/api/finance/repair/receivables';



export default {
  name: 'repairBusiness',
  mixins: [dictionary],
  data() {
    // this.dmsFunc = { dmsFuncId: 55100010 };
    return {
      searchOrdersList: this.createSearchOrdersList(),
      columns: this.createTableColumns(),
      fetchParams: { },
      fetchApi: getOrderList,
      onChangeColumn: [],
    };
  },
  components: {},
  computed: {},
  watch: {},
  methods: {
    createSearchOrdersList() {
      return [
        {
          type: 'INPUT',
          label: '工单号',
          fieldName: 'roNo'
        },
        {
          type: 'SELECT',
          label: '是否结清',
          fieldName: 'payOff',
          itemList: this.createDictList('1004')
        }
      ];
    },
    createTableColumns(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 50,
          fixed: 'left',
          render: props => {
            return (
              <div>
                <el-button size="mini" type="text">
                  操作
                </el-button>
              </div>
            );
          }
                // <el-divider direction="vertical" />
                // <el-button size="mini" type="text" onClick={()=>this.detail(props.row)}>
                //   明细
                // </el-button>
                // <el-divider direction="vertical" />
                // <el-button size="mini" type="text" disabled={props.row.lockFlag === 10041002} onClick={()=>this.removelock(props.row.employeeId)}>
                //   解锁
                // </el-button>
                // <el-divider direction="vertical" />
                // <el-button size="mini" type="text" disabled={props.row.lockFlag === 10041001} onClick={()=>this.lock(props.row.employeeId)}>
                //   锁定
                // </el-button>
        },
        {
          title: '工单开单日期',
          dataIndex: 'RO_CREATE_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '工单号',
          dataIndex: 'RO_NO',
          sorter: true
        },
        {
          title: '工单类型',
          dataIndex: 'RO_TYPE',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.RO_TYPE, '8068')}</span>;
          }
        },
        {
          title: '工单状态',
          dataIndex: 'RO_STATUS',
          sorter: true
        },
        {
          title: '服务专员',
          dataIndex: 'SERVICE_ADVISOR',
          sorter: true,
        },
        {
          title: '操作员',
          dataIndex: 'SERVICE_ADVISOR_ASS',
          sorter: true,
        },
        {
          title: '车牌号',
          dataIndex: 'LICENSE',
          sorter: true,
        },
        {
          title: '维修类型',
          dataIndex: 'REPAIR_TYPE_CODE',
          sorter: true,
          // render: props => {
          //   return <span>{this.createDictText(props.row.REPAIR_TYPE_CODE, '8000')}</span>;
          // }
        },
        {
          title: '是否关单',
          dataIndex: 'BALANCE_CLOSE',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.BALANCE_CLOSE, '1004')}</span>;
          }
        },
        {
          title: '付款方式',
          dataIndex: 'PAY_TYPE_CODE',
          showOverflowTooltip: true,
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.PAY_TYPE_CODE, '8044')}</span>;
          }
        },
        {
          title: '是否结清',
          dataIndex: 'PAY_OFF',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.PAY_OFF, '1004')}</span>;
          }
        },
        {
          title: '交车标识',
          dataIndex: 'DELIVERY_TAG',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.DELIVERY_TAG, '8001')}</span>;
          }
        },
        {
          title: '品牌',
          dataIndex: 'BRAND',
          sorter: true
        },
        {
          title: '车系',
          dataIndex: 'SERIES',
          sorter: true
        },
        {
          title: '车型',
          dataIndex: 'MODEL',
          sorter: true,
        },
        {
          title: '车主编号',
          dataIndex: 'OWNER_NO',
          sorter: true,
        },
        {
          title: '车主',
          dataIndex: 'OWNER_NAME',
          sorter: true
        },
        {
          title: '推荐人',
          dataIndex: 'RECOMMEND_EMP_NAME',
          sorter: true
        },
        {
          title: '推荐单位',
          dataIndex: 'RECOMMEND_CUSTOMER_NAME',
          sorter: true
        },
        {
          title: '车主性质',
          dataIndex: 'OWNER_PROPERTY',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.OWNER_PROPERTY, '8011')}</span>;
          }
        },
        {
          title: '维修金额',
          dataIndex: 'REPAIR_AMOUNT',
          sorter: true
        },
        {
          title: '提交结算时间',
          dataIndex: 'FOR_BALANCE_TIME',
          sorter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '交车日期',
          dataIndex: 'DELIVERY_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '竣工时间',
          dataIndex: 'COMPLETE_TIME',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: 'VIN',
          dataIndex: 'VIN',
          sorter: true,
        },
        {
          title: '进厂行驶里程',
          dataIndex: 'IN_MILEAGE',
          sorter: true,
        },
        {
          title: '出厂行驶里程',
          dataIndex: 'OUT_MILEAGE',
          sorter: true,
        },
        {
          title: '预计交车时间',
          dataIndex: 'END_TIME_SUPPOSED',
          sorter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '送修人电话',
          dataIndex: 'DELIVERER_PHONE',
          sorter: true,
        },
        {
          title: '送修人手机',
          dataIndex: 'DELIVERER_MOBILE',
          sorter: true,
        },
        {
          title: '送修人姓名',
          dataIndex: 'DELIVERER',
          sorter: true,
        },
        {
          title: '发动机号',
          dataIndex: 'ENGINE_NO',
          sorter: true,
        },
        {
          title: '估价单号',
          dataIndex: 'ESTIMATE_NO',
          sorter: true,
        },
        {
          title: '保险公司代码',
          dataIndex: 'INSURATION_CODE',
          sorter: true,
        },
        {
          title: '工时费',
          dataIndex: 'LABOUR_AMOUNT',
          sorter: true,
        },
        {
          title: '维修材料费',
          dataIndex: 'REPAIR_PART_AMOUNT',
          sorter: true,
        },
        {
          title: '销售材料费',
          dataIndex: 'SALES_PART_AMOUNT',
          sorter: true,
        },
        {
          title: '附加项目费',
          dataIndex: 'ADD_ITEM_AMOUNT',
          sorter: true,
        },
        {
          title: '辅料管理费',
          dataIndex: 'OVER_ITEM_AMOUNT',
          sorter: true,
        },
        {
          title: '预约单号',
          dataIndex: 'BOOKING_ORDER_NO',
          sorter: true,
        },
        {
          title: '是否预约',
          dataIndex: 'IS_BOOKING',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.IS_BOOKING, '1004')}</span>;
          }
        },
        {
          title: '预约类别',
          dataIndex: 'BOOKING_TYPE_CODE',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.BOOKING_TYPE_CODE, '8055')}</span>;
          }
        },
        {
          title: '应收金额',
          dataIndex: 'RECEIVABLE_AMOUNT',
          sorter: true,
        },
        {
          title: '结算金额',
          dataIndex: 'TOTAL_AMOUNT',
          sorter: true,
        },
        {
          title: '下次保养日期',
          dataIndex: 'NEXT_MAINTAIN_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '下次保养里程',
          dataIndex: 'NEXT_MAINTAIN_MILEAGE',
          sorter: true,
        },
        {
          title: '是否回访',
          dataIndex: 'IS_TRACE',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.IS_TRACE, '1004')}</span>;
          }
        },
        {
          title: '是否修改预交车时间',
          dataIndex: 'IS_UPDATE_END_TIME_SUPPOSED',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.IS_UPDATE_END_TIME_SUPPOSED, '1004')}</span>;
          }
        },
        {
          title: '不回访原因',
          dataIndex: 'NO_TRACE_REASON',
          sorter: true,
        },
        {
          title: '关单时间',
          dataIndex: 'BALANCE_CLOSE_TIME',
          sorter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '维修技师',
          dataIndex: 'TECHNICIAN',
          sorter: true,
        },
        {
          title: '建档日期',
          dataIndex: 'FOUND_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
          sorter: true,
        },
        {
          title: '备注1',
          dataIndex: 'REMARK1',
          sorter: true,
        },
        {
          title: '结清日期',
          dataIndex: 'SQUARE_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '结算时间',
          dataIndex: 'BALANCE_TIME',
          sorter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '保修日期',
          dataIndex: 'WRT_BEGIN_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '故障描述',
          dataIndex: 'RO_TROUBLE_DESC',
          sorter: true,
        },
        {
          title: '已收金额',
          dataIndex: 'RECEIVED_AMOUNT',
          sorter: true,
        },
        {
          title: '首次报价金额',
          dataIndex: 'FIRST_ESTIMATE_AMOUNT',
          sorter: true,
        },
        {
          title: '预估金额',
          dataIndex: 'ESTIMATE_AMOUNT',
          sorter: true,
        },
        {
          title: '预计开工时间',
          dataIndex: 'ESTIMATE_BEGIN_TIME',
          sorter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '预约时间',
          dataIndex: 'BOOKING_COME_TIME',
          sorter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '结算单打印时间',
          dataIndex: 'PRINT_BALANCE_TIME',
          sorter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        // {
        //   title: '成功预约',
        //   dataIndex: 'RO_CREATE_DATE',
        //   sorter: true,
        // },
        {
          title: '销售折扣抵扣金额',
          dataIndex: 'VOUCHERS_GIFT_AMOUNT',
          sorter: true,
        },
      ]
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.$refs.table.$refs.pageTable.EXECUTE_RESET_HEIGHT();
      });
    },
    async getReceiveDetail(id) {
      const res = await getReceiveDetail(id);
      // console.log(res,'结清')
      this.showWriteOff = true
      this.$nextTick(()=>{
        this.$refs.writeOff.openModel(this.onChangeColumn, res.data)
      })
    },
    getOrderList (val){
      this.fetchParams = Object.assign({}, val);
    },
  },
  mounted() {
    // this.query()
  }
};
</script>

<style lang="less">
</style>
